package rpc.test;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhangyanfei on 2019/7/2.
 *
 * @author zhangyanfei
 * @date 2019/07/02
 */
public class InvokersSelectDemo {

    public static void main(String[] args) {
        List<Invokers> invokers = new ArrayList<>();
        Invokers invokers1 = new Invokers(5, "a");
        Invokers invokers2 = new Invokers(3, "b");
        Invokers invokers3 = new Invokers(2, "c");
        invokers.add(invokers1);
        invokers.add(invokers2);
        invokers.add(invokers3);

        RandomLoadBalance randomLoadBalance = new RandomLoadBalance(invokers);

        int a = 0;
        int b = 0;
        int c = 0;

        for (int i = 0; i < 1000; i++) {
            Invokers temp = randomLoadBalance.doSelect();
            switch (temp.name) {
                case "a":
                    a++;
                    break;
                case "b":
                    b++;
                    break;
                case "c":
                    c++;
                    break;
            }
        }

        System.out.println("a:" + a);
        System.out.println("b:" + b);
        System.out.println("c:" + c);

    }
}
